{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "uint8\n",
      "float32\n",
      "(20000, 10, 1, 64, 64)\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import h5py\n",
    "#% matplotlib inline\n",
    "import matplotlib.pyplot as plt\n",
    "# from IPython import get_ipython\n",
    "# get_ipython().run_line_magic('matplotlib', 'inline')\n",
    "\n",
    "b = np.load('/usr/not-backed-up/unsupervised-videos-master/bouncing_mnist_test.npy')\n",
    "print(b.dtype)\n",
    "b = np.float32(b)\n",
    "b = np.divide(b,float(255))\n",
    "b = np.reshape(b,[10000,20,1,64,64])\n",
    "print(b.dtype)\n",
    "# for i in range(0,20):\n",
    "#     data = np.zeros([1000,10,1,64,64])\n",
    "#     for i in range(10000):\n",
    "#         data[2*i,:,:,:] = b[i,0:10,:,:,:]\n",
    "#         data[2*i+1,:,:,:] = b[i,10:20,:,:,:]\n",
    "#     print(data.shape)\n",
    "\n",
    "#     data_recons = np.zeros([20000,10,1,64,64])\n",
    "#     for i in range(10):\n",
    "#         data_recons[:,i,:,:] = data[:,9-i,:,:]\n",
    "\n",
    "#     h5f = h5py.File('/usr/not-backed-up/1_convlstm/bouncing_mnist_autoencoder_train.h5','w')\n",
    "#     h5f.create_dataset('input',shape = [19000,10,1,64,64], dtype=b.dtype)\n",
    "#     h5f.create_dataset('match',shape = [19000,10,1,64,64], dtype=b.dtype)\n",
    "#     h5f['input'][:] = data[0:19000,:,:,:,:]\n",
    "#     h5f['match'][:] = data_recons[0:19000,:,:,:,:]\n",
    "#     h5f.close()\n",
    "\n",
    "\n",
    "data = np.zeros([20000,10,1,64,64])\n",
    "for i in range(10000):\n",
    "    data[2*i,:,:,:] = b[i,0:10,:,:,:]\n",
    "    data[2*i+1,:,:,:] = b[i,10:20,:,:,:]\n",
    "print(data.shape)\n",
    "\n",
    "data_recons = np.zeros([20000,10,1,64,64])\n",
    "for i in range(10):\n",
    "    data_recons[:,i,:,:] = data[:,9-i,:,:]\n",
    "    \n",
    "h5f = h5py.File('/usr/not-backed-up/1_convlstm/bouncing_mnist_autoencoder_train.h5','w')\n",
    "h5f.create_dataset('input',shape = [19000,10,1,64,64], dtype=b.dtype)\n",
    "h5f.create_dataset('match',shape = [19000,10,1,64,64], dtype=b.dtype)\n",
    "h5f['input'][:] = data[0:19000,:,:,:,:]\n",
    "h5f['match'][:] = data_recons[0:19000,:,:,:,:]\n",
    "h5f.close()\n",
    "\n",
    "\n",
    "# h5f = h5py.File('/usr/not-backed-up/1_convlstm/bouncing_mnist_autoencoder_test.h5','w')\n",
    "# h5f.create_dataset('input',shape = [1000,10,1,64,64], dtype=b.dtype)\n",
    "# h5f.create_dataset('match',shape = [1000,10,1,64,64], dtype=b.dtype)\n",
    "# h5f['input'][:] = data[19000:20000,:,:,:,:]\n",
    "# h5f['match'][:] = data_recons[19000:20000,:,:,:,:]\n",
    "\n",
    "# h5f.close()\n",
    "\n",
    "# # a = b[0:100,0:10,:,:]\n",
    "# # c = np.zeros(a.shape)\n",
    "# # for i in range(10):\n",
    "# #     c[:,i,:,:] = a[:,9-i,:,:]\n",
    "# # plt.figure()\n",
    "# # for i in range(10):\n",
    "# # #     print(i)\n",
    "# #     plt.subplot(2,5,i+1)\n",
    "# #     plt.imshow(a[19,i,0,:,:])\n",
    "# # plt.show()\n",
    "\n",
    "\n",
    "# # plt.figure()\n",
    "# # for i in range(10):\n",
    "# # #     print(i)\n",
    "# #     plt.subplot(2,5,i+1)\n",
    "# #     plt.imshow(c[19,i,0,:,:])\n",
    "# # plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "h5f = h5py.File('/usr/not-backed-up/1_convlstm/bouncing_mnist_autoencoder_test.h5','w')\n",
    "h5f.create_dataset('input',shape = [1000,10,1,64,64], dtype=b.dtype)\n",
    "h5f.create_dataset('match',shape = [1000,10,1,64,64], dtype=b.dtype)\n",
    "h5f['input'][:] = data[19000:20000,:,:,:,:]\n",
    "h5f['match'][:] = data_recons[19000:20000,:,:,:,:]\n",
    "\n",
    "h5f.close()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.13"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
